package com.demo.websocket;

import org.springframework.stereotype.Component;

import com.google.gson.Gson;
import com.outstanding.framework.core.PendingException;
import com.outstanding.plugin.websocket.WebMessage;
import com.outstanding.plugin.websocket.WebSocketSender;
import com.outstanding.plugin.websocket.handler.MessageHandler;


@Component
public class TalkHandler implements  MessageHandler{

	@Override
	public void onMessage(WebMessage message) throws PendingException {
		String param = message.getParam();
		String from = message.getFrom();
		Gson gs = new Gson();
		Words ws = gs.fromJson(param, Words.class);
		String aid = ws.getId();
		Words newws = new Words();
		newws.setId(aid);
		newws.setText("我已经收到了"+ws.getText());
		WebSocketSender.sendMessageToUser(aid, newws);
		
	}

	@Override
	public String cmd() {
		return "talk";
	}

}
